<template>
    <div class="container">
      <headerBar :title="local.msgDetail"  @changeLan="changeLan"></headerBar>
    <div class="all" :style="{paddingTop: pdt+'px'}">
      <div class="top">
        <div class="prev" @click="getInformPrevOrNext('1')">{{local.Previous}}</div>
        <div class="next" @click="getInformPrevOrNext('2')">{{local.Next}}</div>
      </div>
      <div class="msg-detail-panel">
        <div class="msg-detail-title">{{message}}</div>
        <div class="msg-detail-date">{{createTime}}</div>
        <div class="msg-detail-content">{{remark}}</div>
      </div>
    </div>
    </div>
</template>

<script>
import headerBar from '@/components/headerBar'
import card from '@/components/card'
import home from '@/api/home'

export default {
  components: {
    card,
    headerBar
  },
  onLoad (options) {
    this.initLang()
    this.id = options.id
    this.getCustomerInformId(options.id)
    this.pdt = this.globalData.CustomBar
  },
  methods: {
    initLang(){
      this.local = wx.getStorageSync('local')
    },
    async getInformPrevOrNext (type) {
      const {data} = await home.getInformPrevOrNext({type: type, id: this.id})
      if (data == 0) {
        let msg
        if (type==1) msg = `${this.local.Previous}`
        else msg = `${this.local.Next}`
        wx.showToast({
          title: `${this.local.hasNo}${msg}！`,
          duration: 2000,
          icon: 'none'
        })
        return
      }
      this.createTime = data.createTime
      this.message = data.message
      this.remark = data.remark
      this.id = data.id
    },
    changeLan (val) {
      this.local = val
    },
    async getCustomerInformId (id) {
      const data = await home.getCustomerInformId({id: id})
      this.createTime = data.createTime
      this.message = data.message
      this.remark = data.remark
    },
    routerToUrl (url) {
      wx.navigateTo({
        url
      })
    }
  },
  data () {
    return {
      pdt: 66,
      local: wx.getStorageSync('local'),
      logs: [],
      createTime: '',
      message: '',
      remark: '',
      id: ''
    }
  },

  created () {
  }
}
</script>

<style scoped lang="scss">
  @import "index";
.log-list {
  display: flex;
  flex-direction: column;
  padding: 40rpx;
}

.log-item {
  margin: 10rpx;
}
</style>
